import request from '@/utils/request'

// 查询故障报修列表
export function listOrders(query) {
  return request({
    url: '/system/fault-report/list',
    method: 'get',
    params: query
  })
}

// 查询故障报修详细
export function getOrder(reportNo) {
  return request({
    url: `/system/fault-report/${reportNo}`,
    method: 'get'
  })
}

// 新增故障报修
export function addOrder(data) {
  return request({
    url: '/system/fault-report',
    method: 'post',
    data
  })
}

// 修改故障报修
export function updateOrder(data) {
  return request({
    url: '/system/fault-report',
    method: 'put',
    data
  })
}

// 删除故障报修
export function delOrder(reportNo) {
  return request({
    url: `/system/fault-report/${reportNo}`,
    method: 'delete'
  })
}

// 提交故障报修
export function submitOrder(reportNo) {
  return request({
    url: `/system/fault-report/submit/${reportNo}`,
    method: 'post'
  })
}

// 撤回故障报修
export function withdrawOrder(reportNo) {
  return request({
    url: `/system/fault-report/withdraw/${reportNo}`,
    method: 'post'
  })
}

// 承认故障报修
export function acknowledgeOrder(reportNo) {
  return request({
    url: `/system/fault-report/acknowledge/${reportNo}`,
    method: 'post'
  })
}

// 拒绝承认故障报修
export function rejectOrder(reportNo) {
  return request({
    url: `/system/fault-report/reject/${reportNo}`,
    method: 'post'
  })
}

// 获取状态履历
export function getStatusHistory(reportNo) {
  return request({
    url: `/system/fault-report/${reportNo}/history`,
    method: 'get'
  })
}

// 获取报修单（维修详情用于补全）- 走 /system/report/order 控制器
export function getReportOrder(reportNo) {
  return request({
    url: `/system/report/order/${reportNo}`,
    method: 'get'
  })
}
